# f = open('D:/CodeFile/test.txt', 'r')
# result = f.read(2)
# print(result)
# f.close()

# f = open('D:/CodeFile/test.txt', 'r',encoding='utf-8')
# for line in f:
#     print(f'line = {line}')
# f.close()

# f = open('D:/CodeFile/test.txt', 'r')
# for line in f:
#     print(f'line = {line}', end='')
# f.close()

#还可以使用readlines方法直接把整个文件内容读出按照行组织到一个列表。
f = open('D:/CodeFile/test.txt', 'r')
lines = f.readlines()
print(lines)
f.close()

